﻿<Window x:Class="GuidGeneratorWPF.GuidCountWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        mc:Ignorable="d"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
        xmlns:local="clr-namespace:GuidGeneratorWPF"
        Icon="/Resources/Guid.ico"
        Name="guidCountWindow" WindowStartupLocation="CenterScreen"
        Title="GUID Generator" SizeToContent="WidthAndHeight" ResizeMode="NoResize">
    <Window.Resources>
        <Style TargetType="Button">
            <Setter Property="MinWidth" Value="75" />
            <Setter Property="MinHeight" Value="27" />
            <Setter Property="Margin" Value="4" />
        </Style>
        <Style TargetType="Label">
            <Setter Property="VerticalAlignment" Value="Center" />
            <Setter Property="Margin" Value="4" />
        </Style>
        <Style TargetType="TextBox">
            <Setter Property="VerticalAlignment" Value="Center" />
            <Setter Property="Margin" Value="4" />
            <Style.Triggers>
                <Trigger Property="Validation.HasError" Value="True">
                    <Setter Property="ToolTip" Value="{Binding RelativeSource={RelativeSource Self}, Path=(Validation.Errors)[0].ErrorContent}" />
                </Trigger>
            </Style.Triggers>
        </Style>
        <Style TargetType="TextBlock">
            <Setter Property="VerticalAlignment" Value="Center" />
            <Setter Property="Margin" Value="4" />
        </Style>
        <local:InverseBooleanConverter x:Key="inverseBooleanConverter" />
    </Window.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="*" />
            <ColumnDefinition Width="Auto" />
        </Grid.ColumnDefinitions>
        <Label>_Generate </Label>
        <TextBox Grid.Column="1" Name="textBoxCount" MinWidth="50">
            <TextBox.Text>
                <Binding ElementName="guidCountWindow" Path="GuidCountText" ValidatesOnExceptions="True" UpdateSourceTrigger="PropertyChanged">
                    <Binding.ValidationRules>
                        <local:Int32ValidationRule />
                    </Binding.ValidationRules>
                </Binding>
            </TextBox.Text>
        </TextBox>
        <TextBlock Grid.Column="2" Text=" GUIDs" />
        <StackPanel Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="3" Orientation="Horizontal" HorizontalAlignment="Right">
            <Button IsDefault="True" Click="ButtonOK_Click" Content="_OK" IsEnabled="{Binding ElementName=textBoxCount, Path=(Validation.HasError), Converter={StaticResource inverseBooleanConverter}}" />
            <Button IsCancel="True" Click="ButtonCancel_Click">_Cancel</Button>
        </StackPanel>
    </Grid>
</Window>
